#ifndef __MAIN_H
#define __MAIN_H

// http://sdcc.sourceforge.net/doc/sdccman.pdf#3.17 Defines Created by the Compiler
#ifdef __SDCC
#include "at89x52.h"
#else
#include "reg52.h"
#endif

#include "stdlib.h"
#include "stdio.h"
#include "math.h"

#ifndef uchar
#define uchar unsigned char
#endif

#ifndef uint
#define uint unsigned int
#endif

#ifndef ulong
#define ulong unsigned long
#endif

typedef unsigned char BYTE;
typedef unsigned int WORD;

//12MHz
#ifndef fosc
#define fosc 11059200
#endif

#ifdef __SDCC
#define _nop_() __asm nop __endasm
// #define _nop_() __asm NOP __endasm
// NOP and nop are all ok !

// define _nop_() __asm__ (”NOP”)
// build error

#else
#include <intrins.h> //其中有nop函数的定义
#endif

#ifdef __SDCC
#define bit __bit
#define interrupt __interrupt
#define idata __idata
#define pdata __pdata
#define sfr __sfr
#define sbit __sbit
#define at __at
#define code __code
#define using __using
#endif

// P4 port
#ifdef __SDCC
sfr at 0xe8 P4;
sbit at 0xe8 P4_0;
sbit at 0xe9 P4_1;
sbit at 0xea P4_2;
sbit at 0xeb P4_3;
sbit at 0xec P4_4;
sbit at 0xed P4_5;
sbit at 0xee P4_6;
#else //Keil C51
sfr P4 = 0xe8;
sbit P40 = 0xe8;
sbit P41 = 0xe9;
sbit P42 = 0xea;
sbit P43 = 0xeb;
sbit P44 = 0xec;
sbit P45 = 0xed;
sbit P46 = 0xee;
#endif

#define DEBUG

#endif

